add test for fit Locations(Lctns) files. (#765)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Thu, 18 Nov 2021 23:40:49 +0000 (16:40 -0700)
committerGitHub <noreply@github.com>
Thu, 18 Nov 2021 23:40:49 +0000 (16:40 -0700)
* add test for fit Locations(Lctns) files.

* fix new bug with change in Qt6 behavior for fit.

garmin_fit.cc
reference/Lctns_Instinct.csv [new file with mode: 0644]
reference/Lctns_Instinct.fit [new file with mode: 0755]
testo.d/garmin_fit.test

index b32a6c1fc0bb492fa0a9582f299ff109982467dd..ede89adf966e28ab5e49318ada74c7968d51f0df 100644 (file)
@@ -217,13 +217,13 @@ GarminFitFormat::fit_getstring(int size)
   if (fit_data.len < size) {
     throw ReaderException("record truncated: expecting " + std::to_string(size) + " bytes, but only got " + std::to_string(fit_data.len) + ".");
   }
-  QByteArray buf(size + 1, 0);
+  QByteArray buf(size + 1, 0); // almost certainly an extra byte, QByteArray should guarnatee a terminator.
   gbsize_t count = gbfread(buf.data(), size, 1, fin);
   if (count != 1) {
     throw ReaderException("unexpected end of file with fit_data.len=" + std::to_string(fit_data.len) + ".");
   }
   fit_data.len -= size;
-  return QString(buf);
+  return QString(buf.constData());
 }
 
 void
diff --git a/reference/Lctns_Instinct.csv b/reference/Lctns_Instinct.csv
new file mode 100644 (file)
index 0000000..a5b703a
--- /dev/null
@@ -0,0 +1,9 @@
+No,Latitude,Longitude,Name,Altitude\r
+1,50.031985,14.310719,"X",\r
+2,50.101786,14.391518," >  1",235.4\r
+3,50.102963,14.391518,"2",235.4\r
+4,50.104888,14.391045,"3",235.4\r
+5,50.206686,14.260687,"12 SEP 19:07",226.6\r
+6,50.213687,14.307941,"15 SEP 18:47",287.8\r
+7,50.184026,14.367012,"3 OCT 15:42",197.8\r
+8,50.172190,14.239638,"3 OCT 17:33",261.8\r
diff --git a/reference/Lctns_Instinct.fit b/reference/Lctns_Instinct.fit
new file mode 100755 (executable)
index 0000000..57168b8
Binary files /dev/null and b/reference/Lctns_Instinct.fit differ
index 876317ca1468f348c77958e0505a352b48fb2223..a2a5a71da9cb887635b4a67853406da6d5eea76a 100644 (file)
@@ -29,6 +29,9 @@ compare ${REFERENCE}/track/garmin-oregon-700-output.gpx ${TMPDIR}/fit-sample-gar
 gpsbabel -i garmin_fit,recoverymode -f ${REFERENCE}/track/lezyne_super_gps-garmin_fit-sample-bad-endian.fit -o gpx -F ${TMPDIR}/lezyne_super_gps-garmin_fit-sample-bad-endian.gpx 2>/dev/null
 compare ${REFERENCE}/track/lezyne_super_gps-garmin_fit-sample-bad-endian.gpx ${TMPDIR}/lezyne_super_gps-garmin_fit-sample-bad-endian.gpx
 
+gpsbabel -i garmin_fit -f ${REFERENCE}/Lctns_Instinct.fit -o unicsv,utc=0 -F ${TMPDIR}/Lctns_Instinct.csv
+compare ${REFERENCE}/Lctns_Instinct.csv ${TMPDIR}/Lctns_Instinct.csv
+
 #
 # Basic FIT tests (write)
 #